package com.sgl.gk.controller;

import com.sgl.common.annotation.Log;
import com.sgl.common.core.domain.AjaxResult;
import com.sgl.common.enums.BusinessType;
import com.sgl.gk.domain.GkStationConfigurationValues;
import com.sgl.gk.domain.GkStationEvent;
import com.sgl.gk.service.GkStationConfigurationValuesService;
import com.sgl.gk.service.GkStationEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author:xec
 * @date:2022/10/31 18:50
 *
 * 工位交互配置事件表的controller
 **/
@RestController
@RequestMapping("/gk/stationevent")
public class GkStationEventController {

    @Autowired
    GkStationEventService gkStationEventService;

    /**
     * 查询工位交互事件
     * @param gkStationEvent  查询条件
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public AjaxResult list(GkStationEvent gkStationEvent){
        return gkStationEventService.list(gkStationEvent);
    }

    /**
     * 添加工位交互事件
     * @param gkStationEvents
     * @return
     */
    @PostMapping("/add")
    @ResponseBody
    @Log(title = "工位交互配置事件",businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody GkStationEvent gkStationEvents){
        return gkStationEventService.add(gkStationEvents);
    }

    /**
     * 修改工位交互事件
     * @param gkStationEvents
     * @return
     */
    @PostMapping("/edit")
    @ResponseBody
    @Log(title = "工位交互配置事件",businessType = BusinessType.UPDATE)
    public AjaxResult edit(@RequestBody GkStationEvent gkStationEvents){
        return gkStationEventService.edit(gkStationEvents);
    }

    /**
     * 事件保存按钮
     * @param gkStationEvents
     * @return
     */
    @PostMapping("/save")
    @ResponseBody
    @Log(title = "工位交互配置事件",businessType = BusinessType.OTHER)
    public AjaxResult save(@RequestBody GkStationEvent[] gkStationEvents){
        return gkStationEventService.save(gkStationEvents);
    }

    /**
     * 删除工位交互事件
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    @ResponseBody
    @Log(title = "工位交互配置事件",businessType = BusinessType.DELETE)
    public AjaxResult removeByIds(@PathVariable("ids") Long[] ids){
        return gkStationEventService.removeByIds(ids);
    }
}
